/**
 * 1. 创建一个 User 构造器，创建用户 user
 * 2. 每个 user 都有 name、age、career、work 属性
 * 3. career 是 coder 时，work 是 ['写代码','写系分', '修Bug']
 *           是 product manager，work 是 ['订会议室', '写PRD', '催更']
 *           是 boss 时，work 是 ['喝茶', '看报', '见客户']
 *           是 其他时，work 是 []
 */

// 不变：只接受输入，生产对象
function User(name, age, career, work) {
  this.name = name
  this.age = age
  this.career = career
  this.work = work
}

// 变：根据业务进行变动
function Factory(name, age, career) {
  let work
  switch (career) {
    case 'work':
      work = ['写代码', '写系分', '修Bug']
      break
    case 'manager work':
      work = ['订会议室', '写PRD', '催更']
      break
    case 'boss':
      work = ['喝茶', '看报', '见客户']
      break
    default:
      work = []
  }
  return new User(name, age, career, work)
}

const user1 = new Factory('Jack', 20, 'work')
const user2 = new Factory('Mick', 20, 'manager work')
const user3 = new Factory('James', 20, 'boss')
console.log(user1, user2, user3)
